package com.suncam.suncam2.controller;

import com.suncam.suncam2.common.result.ResultVO;
import com.suncam.suncam2.entity.UserDO;
import com.suncam.suncam2.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author LZM
 * @version 1.0
 * @Date 2022/1/13
 * @Description 用户管理接口
 */
@RequestMapping("users")
@RestController
public class UserController {

    private static final Logger log = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private UserService userService;

    @PostMapping
    public void save(@RequestBody UserDO user) {
        log.debug("user : ===> {}",user.toString());
        userService.save(user);

    }

    @GetMapping
    public ResultVO users() {
        List<UserDO> users = userService.listUsers();
        return ResultVO.ok().data("users", users);

    }


}
